﻿using System;
using UnityEngine;
using UnityEngine.UI;


    public class ItemCell : MonoBehaviour
    {
        public ItemData itemData;

        private void Start()
        {
            InitUI();
        }

        private void InitUI()
        {
            transform.Find("countText").GetComponent<Text>().text = itemData.ItemCount.ToString();
            transform.Find("nameText").GetComponent<Text>().text = itemData.ItemName;
            transform.Find("img").GetComponent<Button>().onClick.AddListener(() =>
            {
                itemData.ItemCount += 1;
                transform.Find("countText").GetComponent<Text>().text = itemData.ItemCount.ToString();
            });
        }
    }
